﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "教学任务安排 - 更换授课教师");
		
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");

		currentTab = event.getArg("TabID", "labSearch");
		
		teacherId = event.getArg("TCH_ID");

		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		
		targetArgs = structNew();

		rs_programTask = queryNew("tsk_id");
		rs_commonTask = queryNew("tsk_id");
		rs_openTask = queryNew("tsk_id");
		
		rs_programTaskPK = queryNew("tsk_id");
		rs_commonTaskPK = queryNew("tsk_id");
		rs_openTaskPK = queryNew("tsk_id");

		if ( len(teacherId) ) {
			
			structInsert(targetArgs, "TCH_ID", teacherId);
			
			/* TermProp 第一位当前学期 第二位排课学期 */
			sql = "SELECT 
						a.tsk_id, 
						t_course.course_name, 
						a.cidx, 
						a.task_week, 
						CASE WHEN a.task_time IS NULL THEN '-' ELSE a.task_time END task_time, 
						CASE WHEN a.task_place IS NULL THEN '-' ELSE a.task_place END task_place, 
						t_term.academic_year, 
						t_term.academic_term, 
						t_campus.campus_name, 
						tch.tch_name tch_name, 
						tch_sec.tch_name sec_name, 
						tch_ace.tch_name ace_name 
					FROM 
						t_task a 
						INNER JOIN t_course ON t_course.cid = a.cid 
						INNER JOIN t_term ON t_term.term_id = a.term_id 
						INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
						INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
						INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
						INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
					WHERE 
						(
							tch.tch_id = :teacherId 
							OR 
							tch_sec.tch_id = :teacherId 
							OR 
							tch_ace.tch_id = :teacherId 
						)
						AND 
							SUBSTR(t_term.term_prop, 1, 1) = '1' 
						AND 
							SUBSTR(a.task_prop, 7, 1) = '0' 
					ORDER BY 
						t_term.term_id, t_campus.campus_id, a.cidx ";
						
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
			rs_programTask = queryObj.execute( sql=sql ).getResult();
			
			sql = "SELECT 
						a.tsk_id, 
						t_course.course_name, 
						a.cidx, 
						a.task_week, 
						CASE WHEN a.task_time IS NULL THEN '-' ELSE a.task_time END task_time, 
						CASE WHEN a.task_place IS NULL THEN '-' ELSE a.task_place END task_place, 
						t_term.academic_year, 
						t_term.academic_term, 
						t_campus.campus_name, 
						tch.tch_name tch_name, 
						tch_sec.tch_name sec_name, 
						tch_ace.tch_name ace_name 
					FROM 
						t_task a 
						INNER JOIN t_course ON t_course.cid = a.cid 
						INNER JOIN t_term ON t_term.term_id = a.term_id 
						INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
						INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
						INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
						INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
					WHERE 
						(
							tch.tch_id = :teacherId 
							OR 
							tch_sec.tch_id = :teacherId 
							OR 
							tch_ace.tch_id = :teacherId 
						)
						AND 
						(
							SUBSTR(t_term.term_prop, 1, 1) = '0' 
							AND 
							SUBSTR(t_term.term_prop, 2, 1) = '1' 
						)
						AND 
							SUBSTR(a.task_prop, 7, 1) = '0' 
					ORDER BY 
						t_term.term_id, t_campus.campus_id, a.cidx ";
						
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
			rs_programTaskPK = queryObj.execute( sql=sql ).getResult();
			
			sql = "SELECT 
						a.tsk_id, 
						t_course.course_name, 
						a.cidx, 
						a.task_week, 
						CASE WHEN a.task_time IS NULL THEN '-' ELSE a.task_time END task_time, 
						CASE WHEN a.task_place IS NULL THEN '-' ELSE a.task_place END task_place, 
						t_term.academic_year, 
						t_term.academic_term, 
						t_campus.campus_name, 
						tch.tch_name tch_name, 
						tch_sec.tch_name sec_name, 
						tch_ace.tch_name ace_name 
					FROM 
						t_common_task a 
						INNER JOIN t_course ON t_course.cid = a.cid 
						INNER JOIN t_term ON t_term.term_id = a.term_id 
						INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
						INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
						INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
						INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
					WHERE 
						(
							tch.tch_id = :teacherId 
							OR 
							tch_sec.tch_id = :teacherId 
							OR 
							tch_ace.tch_id = :teacherId 
						)
						AND 
							SUBSTR(t_term.term_prop, 1, 1) = '1' 
						AND 
							SUBSTR(a.task_prop, 7, 1) = '0' 
					ORDER BY 
						t_term.term_id, t_campus.campus_id, a.cidx ";
						
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
			rs_commonTask = queryObj.execute( sql=sql ).getResult();
			
			sql = "SELECT 
						a.tsk_id, 
						t_course.course_name, 
						a.cidx, 
						a.task_week, 
						CASE WHEN a.task_time IS NULL THEN '-' ELSE a.task_time END task_time, 
						CASE WHEN a.task_place IS NULL THEN '-' ELSE a.task_place END task_place, 
						t_term.academic_year, 
						t_term.academic_term, 
						t_campus.campus_name, 
						tch.tch_name tch_name, 
						tch_sec.tch_name sec_name, 
						tch_ace.tch_name ace_name 
					FROM 
						t_common_task a 
						INNER JOIN t_course ON t_course.cid = a.cid 
						INNER JOIN t_term ON t_term.term_id = a.term_id 
						INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
						INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
						INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
						INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
					WHERE 
						(
							tch.tch_id = :teacherId 
							OR 
							tch_sec.tch_id = :teacherId 
							OR 
							tch_ace.tch_id = :teacherId 
						)
						AND 
						(
							SUBSTR(t_term.term_prop, 1, 1) = '0' 
							AND 
							SUBSTR(t_term.term_prop, 2, 1) = '1' 
						)
						AND 
							SUBSTR(a.task_prop, 7, 1) = '0' 
					ORDER BY 
						t_term.term_id, t_campus.campus_id, a.cidx ";
						
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
			rs_commonTaskPK = queryObj.execute( sql=sql ).getResult();
			
			sql = "SELECT 
						a.tsk_id, 
						t_course.course_name, 
						a.cidx, 
						a.task_week, 
						CASE WHEN a.task_time IS NULL THEN '-' ELSE a.task_time END task_time, 
						CASE WHEN a.task_place IS NULL THEN '-' ELSE a.task_place END task_place, 
						t_term.academic_year, 
						t_term.academic_term, 
						t_campus.campus_name, 
						tch.tch_name tch_name, 
						tch_sec.tch_name sec_name, 
						tch_ace.tch_name ace_name 
					FROM 
						t_reopen_task a 
						INNER JOIN t_course ON t_course.cid = a.cid 
						INNER JOIN t_term ON t_term.term_id = a.term_id 
						INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
						INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
						INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
						INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
					WHERE 
						(
							tch.tch_id = :teacherId 
							OR 
							tch_sec.tch_id = :teacherId 
							OR 
							tch_ace.tch_id = :teacherId 
						)
						AND 
							SUBSTR(t_term.term_prop, 1, 1) = '1' 
						AND 
							SUBSTR(a.task_prop, 7, 1) = '0' 
					ORDER BY 
						t_term.term_id, t_campus.campus_id, a.cidx ";
						
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
			rs_openTask = queryObj.execute( sql=sql ).getResult();
			
			sql = "SELECT 
						a.tsk_id, 
						t_course.course_name, 
						a.cidx, 
						a.task_week, 
						CASE WHEN a.task_time IS NULL THEN '-' ELSE a.task_time END task_time, 
						CASE WHEN a.task_place IS NULL THEN '-' ELSE a.task_place END task_place, 
						t_term.academic_year, 
						t_term.academic_term, 
						t_campus.campus_name, 
						tch.tch_name tch_name, 
						tch_sec.tch_name sec_name, 
						tch_ace.tch_name ace_name 
					FROM 
						t_reopen_task a 
						INNER JOIN t_course ON t_course.cid = a.cid 
						INNER JOIN t_term ON t_term.term_id = a.term_id 
						INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
						INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
						INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
						INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
					WHERE 
						(
							tch.tch_id = :teacherId 
							OR 
							tch_sec.tch_id = :teacherId 
							OR 
							tch_ace.tch_id = :teacherId 
						)
						AND 
						(
							SUBSTR(t_term.term_prop, 1, 1) = '0' 
							AND 
							SUBSTR(t_term.term_prop, 2, 1) = '1' 
						)
						AND 
							SUBSTR(a.task_prop, 7, 1) = '0' 
					ORDER BY 
						t_term.term_id, t_campus.campus_id, a.cidx ";
						
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
			rs_openTaskPK = queryObj.execute( sql=sql ).getResult();
						
			if ( rs_programTask.recordCount or rs_commonTask.recordCount or rs_openTask.recordCount or rs_programTaskPK.recordCount or rs_commonTaskPK.recordCount or rs_openTaskPK.recordCount ) {
				currentTab = event.getArg("TabID", "labTask");
			}
			
		}
		
		rs_targetTask = queryNew("tch_id");
		
		if ( len(taskId) and len(taskType) ) {
			
			switch(taskType){
				case "C":
					sql = "SELECT 
								tch.tch_id tch_id, tch.tch_name tch_name, 
								tch_sec.tch_id sec_id, tch_sec.tch_name sec_name, 
								tch_ace.tch_id ace_id, tch_ace.tch_name ace_name 
							FROM 
								t_common_task a
								INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
								INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
								INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
							WHERE 
								a.tsk_id = :taskId ";
					break;
	
				case "P":
					sql = "SELECT 
								tch.tch_id tch_id, tch.tch_name tch_name, 
								tch_sec.tch_id sec_id, tch_sec.tch_name sec_name, 
								tch_ace.tch_id ace_id, tch_ace.tch_name ace_name 
							FROM 
								t_task a
								INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
								INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
								INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
							WHERE 
								a.tsk_id = :taskId ";
					break;
				
				case "R":
					sql = "SELECT 
								tch.tch_id tch_id, tch.tch_name tch_name, 
								tch_sec.tch_id sec_id, tch_sec.tch_name sec_name, 
								tch_ace.tch_id ace_id, tch_ace.tch_name ace_name 
							FROM 
								t_reopen_task a
								INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
								INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
								INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
							WHERE 
								a.tsk_id = :taskId ";
					break;
				
				case "T":
					sql = "SELECT 
								tch.tch_id tch_id, tch.tch_name tch_name, 
								tch_sec.tch_id sec_id, tch_sec.tch_name sec_name, 
								tch_ace.tch_id ace_id, tch_ace.tch_name ace_name 
							FROM 
								t_sport_task a
								INNER JOIN t_teacher tch ON tch.tch_id = a.tch_id 
								INNER JOIN t_teacher tch_sec ON tch_sec.tch_id = a.tch_id_sec 
								INNER JOIN t_teacher tch_ace ON tch_ace.tch_id = a.tch_id_ace 
							WHERE 
								a.tsk_id = :taskId ";
					break;
			}
			
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
			rs_targetTask = queryObj.execute( sql=sql ).getResult();

			if ( rs_targetTask.recordCount ) { 
				currentTab = event.getArg("TabID", "labChange"); 
			}
			
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">教学任务安排</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>更换授课教师
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">查找任课教师</span>
						<cfif rs_programTask.recordCount or rs_commonTask.recordCount or rs_openTask.recordCount or rs_programTaskPK.recordCount or rs_commonTaskPK.recordCount or rs_openTaskPK.recordCount>
							<span <cfif currentTab eq "labTask">class="active"</cfif> id="labTask" tabTarget="Task">教学任务列表</span>
						</cfif>
						<cfif rs_targetTask.recordCount>
							<span <cfif currentTab eq "labChange">class="active"</cfif> id="labChange" tabTarget="Change">更换任课教师</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Search" class="tabContent">

					<form id="formSearch" class="formWrapper Transparent" method="post">
						<div class="label">
							<b>教师姓名或职工号</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('TCH_ID')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button" type="submit" value="搜索教师" />
						</div>
					</form>
					
					<form id="formTeacherPoster" class="hidden_elem" method="post" action="<cfoutput>#buildURL('teacherChange')#</cfoutput>">
						<input id="targetTeacherID" name="TCH_ID" type="hidden" value="" />
					</form>
					
					<div id="formSearchResult" class="UICardTable"></div>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						
						$("#formSearch").submit(function(){
								
							if (processVerfiyForm('formSearch')) {
									
								$.getJSON(
										'<cfoutput>#buildURL("getTeacherByKeywords")#</cfoutput>',
										{
											'Keywords': $("form#formSearch input#Keywords").val(),
											'seed': (new Date()).getTime()
										},
										function(data) {
											
											$div = $("div#formSearchResult").html("").removeClass("hidden_elem");
											$("form#formAuth").addClass("hidden_elem");
												
											for (var i=0; i<data.length; i++) {
											
												var $element = $("<dl><dt><a><i class='sex" + data[i][2] + "'></i><dd><h3>" + data[i][1] + " [" + data[i][3] + "]" + "</h3><p>(" + data[i][0] + ")</p></dd></a></dt></dl>");
													
												$element
													.attr({
														'TeacherID' : data[i][0],
														'TeacherName' : data[i][1]
													})
													.click(function(){
														
														var id = $(this).attr('TeacherID');
														
														$("#targetTeacherID").val(id);
														$("#formTeacherPoster").submit();
														
													})
													.appendTo($div);
													
											}
												
										});
								
							}
								
							return false;
						});
							
						// -->
						//]]>
					</script>
					
				</div>
				
				<cfif rs_programTask.recordCount or rs_commonTask.recordCount or rs_openTask.recordCount>

					<div id="Task" class="tabContent">
						
						<div class="noticeBlock">
							<h3>教学任务</h3>
							<p><span class="img icon16x16 message"></span>下列是该任课教师在当前学期所承担的教学任务清单</p>
							<hr/>
						</div>
						
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="30"></td>
									<td>开课类别</td>
									<td>学期</td>
									<td>教学班</td>
									<td>校区</td>
									<td>任课教师</td>
									<td>上课时间</td>
									<td>上课地点</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
								
								<cfif rs_programTask.recordCount>
									<tr class="breakRows">
										<td colspan="8"></td>
									</tr>
								</cfif>
								
								<cfset row = 0 />
                                <cfloop query="rs_programTask">
									
									<cfset row++ />
									<cfset structInsert(targetArgs, "TSK", rs_programTask.tsk_id, true) />
									<cfset structInsert(targetArgs, "TT", "P", true) />
									
									<tr class="editRows <cfif rs_programTask.tsk_id eq taskId>targetRow</cfif>" rowid="<cfoutput>#rs_programTask.tsk_id#</cfoutput>">
										<td class="index">P.<cfoutput>#row#</cfoutput></td>
										<td>计划课程</td>
										<td><span class="numeric"><cfoutput>#rs_programTask.academic_year#</cfoutput>-<cfoutput>#rs_programTask.academic_term#</cfoutput></span></td>
										<td><cfoutput>#rs_programTask.course_name#</cfoutput><span class="numeric">-<cfoutput>#rs_programTask.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_programTask.campus_name#</cfoutput></td>
										<td>
											<cfoutput>#rs_programTask.tch_name#</cfoutput>
											<cfif rs_programTask.tch_name neq rs_programTask.sec_name> / <cfoutput>#rs_programTask.sec_name#</cfoutput></cfif>
											<cfif rs_programTask.sec_name neq rs_programTask.ace_name and rs_programTask.tch_name neq rs_programTask.ace_name> / <cfoutput>#rs_programTask.ace_name#</cfoutput></cfif>
										</td>
										<td><cfoutput>#replace(mathAdvice.convertTaskTime(rs_programTask.task_time), ",", "<br/>", "all")#</cfoutput></td>
										<td><cfoutput>#replace(rs_programTask.task_place, ",", "<br/>", "all")#</cfoutput></td>
										<td><a title="更换任课教师" href="<cfoutput>#buildURL('teacherChange', targetArgs)#</cfoutput>" class="stat advisor"></a></td>
									</tr>
								</cfloop>
								
								<cfif rs_commonTask.recordCount>
									<tr class="breakRows">
										<td colspan="8"></td>
									</tr>
								</cfif>
								
								<cfset row = 0 />
                                <cfloop query="rs_commonTask">
									
									<cfset row++ />
									<cfset structInsert(targetArgs, "TSK", rs_commonTask.tsk_id, true) />
									<cfset structInsert(targetArgs, "TT", "C", true) />
									
									<tr class="editRows <cfif rs_commonTask.tsk_id eq taskId>targetRow</cfif>" rowid="<cfoutput>#rs_commonTask.tsk_id#</cfoutput>">
										<td class="index">C.<cfoutput>#row#</cfoutput></td>
										<td>全校通选课</td>
										<td><span class="numeric"><cfoutput>#rs_commonTask.academic_year#</cfoutput>-<cfoutput>#rs_commonTask.academic_term#</cfoutput></span></td>
										<td><cfoutput>#rs_commonTask.course_name#</cfoutput><span class="numeric">-<cfoutput>#rs_commonTask.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_commonTask.campus_name#</cfoutput></td>
										<td>
											<cfoutput>#rs_commonTask.tch_name#</cfoutput>
											<cfif rs_commonTask.tch_name neq rs_commonTask.sec_name> / <cfoutput>#rs_commonTask.sec_name#</cfoutput></cfif>
											<cfif rs_commonTask.sec_name neq rs_commonTask.ace_name and rs_commonTask.tch_name neq rs_commonTask.ace_name> / <cfoutput>#rs_commonTask.ace_name#</cfoutput></cfif>
										</td>
										<td><cfoutput>#replace(mathAdvice.convertTaskTime(rs_commonTask.task_time), ",", "<br/>", "all")#</cfoutput></td>
										<td><cfoutput>#replace(rs_commonTask.task_place, ",", "<br/>", "all")#</cfoutput></td>
										<td><a title="更换任课教师" href="<cfoutput>#buildURL('teacherChange', targetArgs)#</cfoutput>" class="stat advisor"></a></td>
									</tr>
								</cfloop>
								
								<cfif rs_openTask.recordCount>
									<tr class="breakRows">
										<td colspan="8"></td>
									</tr>
								</cfif>
								
								<cfset row = 0 />
                                <cfloop query="rs_openTask">
									
									<cfset row++ />
									<cfset structInsert(targetArgs, "TSK", rs_openTask.tsk_id, true) />
									<cfset structInsert(targetArgs, "TT", "R", true) />
									
									<tr class="editRows <cfif rs_openTask.tsk_id eq taskId>targetRow</cfif>" rowid="<cfoutput>#rs_openTask.tsk_id#</cfoutput>">
										<td class="index">R.<cfoutput>#row#</cfoutput></td>
										<td>单开班课程</td>
										<td><span class="numeric"><cfoutput>#rs_openTask.academic_year#</cfoutput>-<cfoutput>#rs_openTask.academic_term#</cfoutput></span></td>
										<td><cfoutput>#rs_openTask.course_name#</cfoutput><span class="numeric">-<cfoutput>#rs_openTask.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_openTask.campus_name#</cfoutput></td>
										<td>
											<cfoutput>#rs_openTask.tch_name#</cfoutput>
											<cfif rs_openTask.tch_name neq rs_openTask.sec_name> / <cfoutput>#rs_openTask.sec_name#</cfoutput></cfif>
											<cfif rs_openTask.sec_name neq rs_openTask.ace_name and rs_openTask.tch_name neq rs_openTask.ace_name> / <cfoutput>#rs_openTask.ace_name#</cfoutput></cfif>
										</td>
										<td><cfoutput>#replace(mathAdvice.convertTaskTime(rs_openTask.task_time), ",", "<br/>", "all")#</cfoutput></td>
										<td><cfoutput>#replace(rs_openTask.task_place, ",", "<br/>", "all")#</cfoutput></td>
										<td><a title="更换任课教师" href="<cfoutput>#buildURL('teacherChange', targetArgs)#</cfoutput>" class="stat advisor"></a></td>
									</tr>
								</cfloop>
								
							</tbody>
						</table>
						
					</div>
					
				</cfif>
				
				<cfif rs_programTaskPK.recordCount or rs_commonTaskPK.recordCount or rs_openTaskPK.recordCount>
					
					<div id="Task" class="tabContent">

						<div class="noticeBlock">
							<h3>排课任务</h3>
							<p><span class="img icon16x16 message"></span>下列是该任课教师在排课学期所承担的教学任务清单</p>
							<hr/>
						</div>
						
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="30"></td>
									<td>开课类别</td>
									<td>学期</td>
									<td>教学班</td>
									<td>校区</td>
									<td>任课教师</td>
									<td>上课时间</td>
									<td>上课地点</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
							
								<cfif rs_programTaskPK.recordCount>
									<tr class="breakRows">
										<td colspan="8"></td>
									</tr>
								</cfif>
								
								<cfset row = 0 />
                                <cfloop query="rs_programTaskPK">
									
									<cfset row++ />
									<cfset structInsert(targetArgs, "TSK", rs_programTaskPK.tsk_id, true) />
									<cfset structInsert(targetArgs, "TT", "P", true) />
									
									<tr class="editRows <cfif rs_programTaskPK.tsk_id eq taskId>targetRow</cfif>" rowid="<cfoutput>#rs_programTaskPK.tsk_id#</cfoutput>">
										<td class="index">P.<cfoutput>#row#</cfoutput></td>
										<td>计划课程</td>
										<td><span class="numeric"><cfoutput>#rs_programTaskPK.academic_year#</cfoutput>-<cfoutput>#rs_programTaskPK.academic_term#</cfoutput></span></td>
										<td><cfoutput>#rs_programTaskPK.course_name#</cfoutput><span class="numeric">-<cfoutput>#rs_programTaskPK.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_programTaskPK.campus_name#</cfoutput></td>
										<td>
											<cfoutput>#rs_programTaskPK.tch_name#</cfoutput>
											<cfif rs_programTaskPK.tch_name neq rs_programTaskPK.sec_name> / <cfoutput>#rs_programTaskPK.sec_name#</cfoutput></cfif>
											<cfif rs_programTaskPK.sec_name neq rs_programTaskPK.ace_name and rs_programTaskPK.tch_name neq rs_programTaskPK.ace_name> / <cfoutput>#rs_programTaskPK.ace_name#</cfoutput></cfif>
										</td>
										<td><cfoutput>#replace(mathAdvice.convertTaskTime(rs_programTaskPK.task_time), ",", "<br/>", "all")#</cfoutput></td>
										<td><cfoutput>#replace(rs_programTaskPK.task_place, ",", "<br/>", "all")#</cfoutput></td>
										<td><a title="更换任课教师" href="<cfoutput>#buildURL('teacherChange', targetArgs)#</cfoutput>" class="stat advisor"></a></td>
									</tr>
								</cfloop>
								
								<cfif rs_commonTaskPK.recordCount>
									<tr class="breakRows">
										<td colspan="8"></td>
									</tr>
								</cfif>
								
								<cfset row = 0 />
                                <cfloop query="rs_commonTaskPK">
									
									<cfset row++ />
									<cfset structInsert(targetArgs, "TSK", rs_commonTaskPK.tsk_id, true) />
									<cfset structInsert(targetArgs, "TT", "C", true) />
									
									<tr class="editRows <cfif rs_commonTaskPK.tsk_id eq taskId>targetRow</cfif>" rowid="<cfoutput>#rs_commonTaskPK.tsk_id#</cfoutput>">
										<td class="index">C.<cfoutput>#row#</cfoutput></td>
										<td>全校通选课</td>
										<td><span class="numeric"><cfoutput>#rs_commonTaskPK.academic_year#</cfoutput>-<cfoutput>#rs_commonTaskPK.academic_term#</cfoutput></span></td>
										<td><cfoutput>#rs_commonTaskPK.course_name#</cfoutput><span class="numeric">-<cfoutput>#rs_commonTaskPK.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_commonTaskPK.campus_name#</cfoutput></td>
										<td>
											<cfoutput>#rs_commonTaskPK.tch_name#</cfoutput>
											<cfif rs_commonTaskPK.tch_name neq rs_commonTaskPK.sec_name> / <cfoutput>#rs_commonTaskPK.sec_name#</cfoutput></cfif>
											<cfif rs_commonTaskPK.sec_name neq rs_commonTaskPK.ace_name and rs_commonTaskPK.tch_name neq rs_commonTaskPK.ace_name> / <cfoutput>#rs_commonTaskPK.ace_name#</cfoutput></cfif>
										</td>
										<td><cfoutput>#replace(mathAdvice.convertTaskTime(rs_commonTaskPK.task_time), ",", "<br/>", "all")#</cfoutput></td>
										<td><cfoutput>#replace(rs_commonTaskPK.task_place, ",", "<br/>", "all")#</cfoutput></td>
										<td><a title="更换任课教师" href="<cfoutput>#buildURL('teacherChange', targetArgs)#</cfoutput>" class="stat advisor"></a></td>
									</tr>
								</cfloop>
								
								<cfif rs_openTaskPK.recordCount>
									<tr class="breakRows">
										<td colspan="8"></td>
									</tr>
								</cfif>
								
								<cfset row = 0 />
                                <cfloop query="rs_openTaskPK">
									
									<cfset row++ />
									<cfset structInsert(targetArgs, "TSK", rs_openTaskPK.tsk_id, true) />
									<cfset structInsert(targetArgs, "TT", "R", true) />
									
									<tr class="editRows <cfif rs_openTaskPK.tsk_id eq taskId>targetRow</cfif>" rowid="<cfoutput>#rs_openTaskPK.tsk_id#</cfoutput>">
										<td class="index">R.<cfoutput>#row#</cfoutput></td>
										<td>单开班课程</td>
										<td><span class="numeric"><cfoutput>#rs_openTaskPK.academic_year#</cfoutput>-<cfoutput>#rs_openTaskPK.academic_term#</cfoutput></span></td>
										<td><cfoutput>#rs_openTaskPK.course_name#</cfoutput><span class="numeric">-<cfoutput>#rs_openTaskPK.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_openTaskPK.campus_name#</cfoutput></td>
										<td>
											<cfoutput>#rs_openTaskPK.tch_name#</cfoutput>
											<cfif rs_openTaskPK.tch_name neq rs_openTaskPK.sec_name> / <cfoutput>#rs_openTaskPK.sec_name#</cfoutput></cfif>
											<cfif rs_openTaskPK.sec_name neq rs_openTaskPK.ace_name and rs_openTaskPK.tch_name neq rs_openTaskPK.ace_name> / <cfoutput>#rs_openTaskPK.ace_name#</cfoutput></cfif>
										</td>
										<td><cfoutput>#replace(mathAdvice.convertTaskTime(rs_openTaskPK.task_time), ",", "<br/>", "all")#</cfoutput></td>
										<td><cfoutput>#replace(rs_openTaskPK.task_place, ",", "<br/>", "all")#</cfoutput></td>
										<td><a title="更换任课教师" href="<cfoutput>#buildURL('teacherChange', targetArgs)#</cfoutput>" class="stat advisor"></a></td>
									</tr>
								</cfloop>
								
							</tbody>
						</table>
						
					</div>
					
				</cfif>

				<cfif rs_targetTask.recordCount>
					
					<div id="Change" class="tabContent">
						
						<div class="noticeBlock">
							<h3>更换任务授课教师</h3>
							<p><span class="img icon16x16 message"></span>这里您可以设置该课程的主讲及辅助教师. 注意: 如果该课程有两名不同授课教师共同承担, 您需要根据周次设置该周任课教师</p>
							<hr/>
						</div>
						
						<div id="formBox">
							
							<form id="formModify" onSubmit="javascript:return processVerfiyForm('formModify');" class="formWrapper" method="post" action="<cfoutput>#buildURL('taskChangeTeacherDo')#</cfoutput>">
								
								<input type="hidden" name="TaskID" value="<cfoutput>#taskId#</cfoutput>" />
								<input type="hidden" name="TaskType" value="<cfoutput>#taskType#</cfoutput>" />
								<input type="hidden" name="TCH_ID" value="<cfoutput>#teacherId#</cfoutput>" />

								<div class="label">
									<b>主讲教师</b>
									<input id="TeacherID" name="TeacherID" type="hidden" value="<cfoutput>#rs_targetTask.tch_id#</cfoutput>" />
									<input name="TeacherName" id="TeacherName" type="text" disabled="disabled" class="typeTextDynamic " verification="required" value="<cfoutput>#rs_targetTask.tch_name#</cfoutput>" /><span id="teacherTrigger" class="btnSearch"></span>
									<p class="notice">该名教师需要承担该课程的主要授课内容</p>
								</div>

								<div class="label">
									<b>第二主讲教师</b>
									<input id="TeacherSecondaryID" name="TeacherSecondaryID" type="hidden" value="<cfoutput>#rs_targetTask.sec_id#</cfoutput>" />
									<input id="TeacherSecondaryName" name="TeacherSecondaryName" type="text" disabled="disabled" class="typeTextDynamic " verification="required" value="<cfoutput>#rs_targetTask.sec_name#</cfoutput>" /><span id="teacherSecondaryTrigger" class="btnSearch"></span>
									<p class="notice">如该门课程是授课团队, 该课程有两名教师共同完成, 则可以设置另一名主讲教师</p>
								</div>
								
								<div class="label">
									<b>助课教师</b>
									<input id="TeacherAssistID" name="TeacherAssistID" type="hidden" value="<cfoutput>#rs_targetTask.ace_id#</cfoutput>" />
									<input id="TeacherAssistName" name="TeacherAssistName" type="text" disabled="disabled" class="typeTextDynamic " verification="required" value="<cfoutput>#rs_targetTask.ace_name#</cfoutput>" /><span id="teacherAssistTrigger" class="btnSearch"></span>
									<p class="notice">如该门课程需要助课教师或该课程需要他人协助提交课程成绩时, 可以设置一名助课教师</p>
								</div>
								
								<hr/>
							
								<div class="lable">
									<input class="button1" type="submit" value="更新教学任务" />
								</div>
								
							</form>

						</div>
						
						<div id="resultBox" class="hidden_elem">
							
							<form id="formModifySearch" class="formWrapper Transparent" method="post">
								<input type="hidden" id="opType" name="opType" value="ALL" />
								
								<div class="label">
									<b>更换的教师姓名或职工号</b>
									<input name="TeacherKeyword" id="TeacherKeyword" type="text" class="typeText" verification="required" maxlength="128" value="" />
								</div>
								<hr/>
								<div class="lable">
									<input class="button" type="submit" value="查找新教师" />
									<input id="formModifyReset" class="button1" type="button" value="返回" />
								</div>
							</form>
							
							<div id="formModifySearchResult" class="UICardTable"></div>
							
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								
								$("#formModifyReset").click(function(){
									
									$("#resultBox").addClass("hidden_elem");
									$("#formBox").removeClass("hidden_elem");
									
								});
								
								$("#teacherTrigger").click(function(){
									
									$("#formBox").addClass("hidden_elem");
									$("#resultBox").removeClass("hidden_elem");
									
									$("#opType").val("ALL");
									
								});
								
								$("#teacherSecondaryTrigger").click(function(){
									
									$("#formBox").addClass("hidden_elem");
									$("#resultBox").removeClass("hidden_elem");
									
									$("#opType").val("SEC");
									
								});
								
								$("#teacherAssistTrigger").click(function(){
									
									$("#formBox").addClass("hidden_elem");
									$("#resultBox").removeClass("hidden_elem");
									
									$("#opType").val("AST");
									
								});
								
								$("#formModifySearch").submit(function(){
									
									if (processVerfiyForm('formModifySearch')) {
									
										$.getJSON(
												'<cfoutput>#buildURL("getTeacherByKeywords")#</cfoutput>',
												{
													'Keywords': $("form#formModifySearch input#TeacherKeyword").val(),
													'seed': (new Date()).getTime()
												},
												function(data) {
											
													$div = $("div#formModifySearchResult").html("").removeClass("hidden_elem");
												
													for (var i=0; i<data.length; i++) {
											
														var $element = $("<dl><dt><a><i class='sex" + data[i][2] + "'></i><dd><h3>" + data[i][1] + " [" + data[i][3] + "]" + "</h3><p>(" + data[i][0] + ")</p></dd></a></dt></dl>");
													
														$element
																.attr({
																		'TeacherID' : data[i][0],
																		'TeacherName' : data[i][1]
																	})
																.click(function(){
														
																		var id = $(this).attr('TeacherID');
																		var name = $(this).attr('TeacherName');
																		
																		var opt = $("#opType").val();
																		
																		switch (opt) {
																			case "ALL":

																				$("#TeacherID").val(id);
																				$("#TeacherName").val(name);
																				
																				$("#TeacherSecondaryID").val(id);
																				$("#TeacherSecondaryName").val(name);
																				
																				$("#TeacherAssistID").val(id);
																				$("#TeacherAssistName").val(name);
																				
																				break;
																				
																			case "SEC":
																				
																				$("#TeacherSecondaryID").val(id);
																				$("#TeacherSecondaryName").val(name);
																				
																				break;
																			
																			case "AST":
																			
																				$("#TeacherAssistID").val(id);
																				$("#TeacherAssistName").val(name);
																			
																				break;
																		}
														
																		
																		
																		$("#resultBox").addClass("hidden_elem");
																		$("#formBox").removeClass("hidden_elem");
														
																	})
																.appendTo($div);
													
													}
												
												});
								
									}
								
									return false;
									
								});
								
								// -->
								//]]>
							</script>
							
						</div>
						
						
						
						
					</div>
					
				</cfif>
				
			</div>
		</li>
	</ul>
</div>
